package com.shoesmail.domain.vo;

import com.shoesmail.enums.ReturnStateEnum;
import lombok.Getter;

/**
 * @author ：CDB
 * @description：统一返回格式
 * @date ：2025/9/16 22:22
 */
@Getter
public class JsonResultVo<T> {
    private int stateCode;

    private String desc;

    private T data;

    private JsonResultVo(int stateCode,String desc,T data){
        this.data = data;
        this.stateCode = stateCode;
        this.desc = desc;
    }

    public static<T> JsonResultVo<T> fail(String desc){
        return new JsonResultVo<>(ReturnStateEnum.FAIL.getCode(),desc,null);
    }

    public static<T> JsonResultVo<T> success(String desc,T data){
        return new JsonResultVo<>(ReturnStateEnum.SUCCESS.getCode(),desc,data);
    }

    public static<T> JsonResultVo<T> fail(int code,String desc){
        return new JsonResultVo<>(code,desc,null);
    }

}
